<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){
	if($_RQ['goodsid']){
		$_SESSION['goodsid']=intval($_RQ['goodsid']);
	}
	if(!$_SESSION['goodsid']){
		exi('商品找不到！','error');
	}
	if(empty($this->plugin_exists('jy_vote'))){
		exi('没有获得场景投票应用权限，联系管理员！','error');
	}
	$buyxiu=$this->plugin_setting('buyxiu');
	$return['cuxiao']=array('0'=>'免送','1'=>'减免','2'=>'打折','3'=>'抵现');
	if($buyxiu['cuxiao']==1){
		$buyxiu['desc']='减免'.$buyxiu['jianmian'].'元';
	}elseif($buyxiu['cuxiao']==2){
		$buyxiu['desc']='打'.$buyxiu['dazhe'].'折';
	}elseif($buyxiu['cuxiao']==3){
		$buyxiu['desc']='抵现'.$buyxiu['dixian'].'元';
	}else{
		$buyxiu['desc']='免费送';
	}
	$return['buyxiu']=$buyxiu;
	$goods=pdo_get('jy_weishop_goods',array('id'=>$_SESSION['goodsid'],'uniacid'=>$_SESSION['uniacid']));
	$item=pdo_get('jy_vote_opus',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'goodsid'=>$_SESSION['goodsid']));
	$return['islikes']=$item['likes']?:0;
	if($item){
		$id=$item['id'];
		//exi('','','jy_vote/o_detail//id='.$item['id']);
	}
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if(!$postdata['title']){
			exi('秀标题不能为空！');
		}
		if(!$postdata['description']){
			exi('秀描述不能为空！');
		}
		if($basic['needpass']){
			$status=0;
		}else{
			$status=1;
		}
		$id=$postdata['id'];
		if($id){
			$data=array(
				'title'=>$postdata['title'],
				'description'=>$postdata['description'],
			);
			pdo_update('jy_vote_opus',$data,array('id'=>$id));
		}else{
			$insert=array(
				'uniacid'=>$_SESSION['uniacid'],
				'mid'=>$_SESSION['uid'],
				'rid'=>0,
				'title'=>$postdata['title'],
				'thumb'=>$goods['image'],
				'description'=>$postdata['description'],
				'opus_images'=>$goods['images'],
				'plugin'=>'jy_weishop',
				'status'=>1,
				'isshow'=>1,
				'goodsid'=>$_SESSION['goodsid'],
				'createtime'=>TIMESTAMP
			);
			pdo_insert('jy_vote_opus',$insert);
			$id=pdo_insertid();
		}
		exi('','success','jy_vote/o_detail//id='.$id);
	}
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','groupid','avatar','nickname'));
	if($item){
		$return['post']=array(
			'id'=>$item['id'],
			'title'=>$item['title'],
			'description'=>$item['description'],
		);
	}else{
		$return['post']=array(
			'title'=>'我喜欢<'.$goods['title'].'>商品！',
			'description'=>'我“'.$member['nickname'].'”为<'.$goods['title'].'>商品代言！满赞'.$buyxiu['desc'].'啦！大家走过路过,随手点个赞！支持一下！',
		);
	}
	$return['post']['opus_images']=array();
	$return['list']=$list;
	exi($return);

}